﻿@model IEnumerable<DynamicLinqWebDocs.Models.Class>

@{
    ViewBag.Title = "Library Reference";
}

<h2>@ViewBag.Title</h2>

@foreach (var ns in Model.GroupBy(x => x.Namespace).OrderBy(x => x.Key))
{
    var interfaces = @ns.Where(x => x.IsInterface).ToArray();
    var classes = @ns.Where(x => !x.IsInterface).ToArray();
    
    <h3>Namespace: @ns.Key</h3>

    if (interfaces.Length > 0)
    {
        <table class="table">
            <thead>
                <tr>
                    <th>Interface</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var interfaceObj in interfaces.OrderBy(x => x.Name))
                {
                    <tr>
                        <td>@Html.ActionLink(interfaceObj.Name, "Class", "Library", new { className = interfaceObj.Name }, null)</td>
                        <td>@Html.FormatMarkdown(interfaceObj.Description)</td>
                    </tr>
                }
            </tbody>
        </table>
    }

    if (classes.Length > 0)
    {
        <table class="table">
            <thead>
                <tr>
                    <th>Class</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var classObj in classes.OrderBy(x => x.Name))
                {
                    <tr>
                        <td>@Html.ActionLink(classObj.Name, "Class", "Library", new { className = classObj.Name }, null)</td>
                        <td>@Html.FormatMarkdown(classObj.Description)</td>
                    </tr>
                }
            </tbody>
        </table>
    }
}